<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: checkout_success.php 165 2013-09-22 07:54:07Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 165 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:54:07 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

include ('includes/application_top.php');

$smarty = new Smarty;

require(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');

if (!isset($_SESSION['customer_id']))
	redirect(href_link(FILENAME_SHOPPING_CART));

if (isset($_GET['action']) && ($_GET['action'] == 'update')) {
	if ($_SESSION['account_type'] != 1)
		redirect(href_link(FILENAME_DEFAULT));
	else
		redirect(href_link(FILENAME_LOGOFF));
}
$breadcrumb->add(NAVBAR_TITLE_1_CHECKOUT_SUCCESS);
$breadcrumb->add(NAVBAR_TITLE_2_CHECKOUT_SUCCESS);

require(DIR_WS_INCLUDES.'header.php');

$orders = $db->db_query("SELECT orders_id, orders_status from ".TABLE_ORDERS." WHERE customers_id = '".$_SESSION['customer_id']."' ORDER BY orders_id desc limit 1");
$last_order = $orders->fields['orders_id'];
$order_status = $orders->fields['orders_status'];

$smarty->assign('FORM_ACTION', draw_form('order', href_link(FILENAME_CHECKOUT_SUCCESS, 'action=update', 'SSL')));
$smarty->assign('BUTTON_CONTINUE', image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE));
$smarty->assign('BUTTON_PRINT', '<img alt="Print" src="images/button_print.gif" style="cursor:pointer" onclick="window.open(\''.href_link(FILENAME_PRINT_ORDER, 'oID='.$orders->fields['orders_id']).'\', \'popup\', \'toolbar=0, width=640, height=600\')" />');
$smarty->assign('FORM_END', '</form>');

$gv_result = $db->db_query("SELECT amount FROM ".TABLE_COUPON_GV_CUSTOMER." WHERE customer_id='".$_SESSION['customer_id']."'");
if ($gv_result->_numOfRows)
	if ($gv_result->fields['amount'] > 0)
		$smarty->assign('GV_SEND_LINK', href_link(FILENAME_GV_SEND));

if (GOOGLE_CONVERSION == 'true') {
	$smarty->assign('google_tracking', 'true');
	$smarty->assign('tracking_code', '
		<noscript>
		<a href="http://services.google.com/sitestats/'.GOOGLE_LANG.'.html" onclick="window.open(this.href); return false;">
		<img height=27 width=135 border=0 src="http://www.googleadservices.com/pagead/conversion/'.GOOGLE_CONVERSION_ID.'/?hl='.GOOGLE_LANG.'" />
		</a>
		</noscript>');
}

if(TRUSTED_SHOP_STATUS == 'true')
	include (DIR_WS_MODULES.'trusted_shops.php');

if(DOWNLOAD_ENABLED == 'true')
	include (DIR_WS_MODULES.'downloads.php');

if(TREEPODIA_STATUS == 'true') {
	$treep .= '<script type="text/javascript">document.write(unescape("%3Cscript src=\'"+document.location.protocol+"//api.treepodia.com/video/Treepodia.js\' type=\'text/javascript\'%3E%3C/script%3E"));</script>';
	$products = $db->db_query("SELECT
									p.products_id
								FROM
									".TABLE_PRODUCTS." p,
									".TABLE_ORDERS_PRODUCTS." op
								WHERE
									op.orders_id = '".$orders->fields['orders_id']."'
								AND
									p.products_id = op.products_id
								GROUP BY
									products_id");
	if($products->_numOfRows) {
		$treep .= '<script type="text/javascript">function initTreepodia(){try{'."\n"; 
		while(!$products->EOF) {
			$treep .= 'Treepodia.getProduct(\''.TREEPODIA_UUID.'\',\''.$products->fields['products_id'].'\').logAddToCart();'."\n";
			$products->MoveNext();
		}
		$treep .= '}catch(e){}}</script>';
		$smarty->assign('treepodia', $treep);
	}
}

$smarty->assign('language', $_SESSION['language']);
$smarty->caching = false;
$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/checkout_success.html');

$smarty->assign('language', $_SESSION['language']);
$smarty->assign('main_content', $main_content);
$smarty->caching = false;
if (!defined('RM'))
	$smarty->loadFilter('output', 'note');
$smarty->loadFilter('output','trimwhitespace');
$smarty->display(CURRENT_TEMPLATE.'/index.html');
include ('includes/application_bottom.php');
?>